<fieldset>
    <legend>Customer Contract List</legend>
    <table class="data">
        <thead>
            <tr>
                <th width="50px"><?php echo 'No'; ?></th>
                <th width="100px"><?php echo 'Customer no.'; ?></th>
                <th><?php echo 'Customer Name'; ?></th>
                <th class="action">&nbsp;</th>
            </tr>
        </thead>
        <tbody>
            <?php if (empty($this->data)) : // ถ้าไม่มีข้อมูล ?>
            <tr>
                <td colspan="6"><div class="fail-flash">This Vendor doesn't have any contract customer.</div></td>
            </tr>
            <? else : // ถ้ามีข้อมูล ?>
                <?php $i = 0;
                foreach($this->data as $CS): ?>
                    <?php
                    $tableCell = array();
                    $tableCell[] = ++$i;
                    $tableCell[] = $CS['Customer']['cust_no'];
                    $tableCell[] = $CS['Customer']['name'];
                    $tableCell[] = $my->confirmLink($html->image('icon/delete.png', array('title' => 'delete', 'alt' => 'delete')), "{$this->name}/delete_contract/{$CS['CustomerSupplier']['id']}", 'Do you want to remove \"' . $CS['Customer']['name'] . '\" from Customer contract list?', 'divCustomerSupplier', false);
                    echo $html->tableCells($tableCell, array('class' => 'odd-cell'), array('class' => 'even-cell'));
                    ?>
                <?php endforeach; ?>
            <?php endif; ?>
            <?php if (!empty($customers)) : // ถ้ายังมีรายการ customer ที่ไม่ได้ contract?>
            <tr>
                <td>&nbsp;</td>
                <td colspan="4">
                        <?php echo $ajax->form(null, 'post', array('update'=>'divCustomerSupplier', 'indicator' => 'indicator', 'url' => array('controller'=>'suppliers','action'=>'save_contract'))); ?>
                        <?php echo $form->select('CustomerSupplier.customer_id', $customers); ?>
                        <?php echo $form->hidden('CustomerSupplier.supplier_id', array('value' => $supplier_id)); ?>
                    <span class="toolbar" style="border: none; margin: 0px;">
                            <?php echo $this->element('toolbar', array('buttons' => array(array('save' => array('message' => 'Do you want to add this customer to contract list?'))))); ?>
                    </span>
                        <?php echo $form->end(); ?>
                </td>
            </tr>
            <?php endif; ?>
        </tbody>
    </table>
    <?php //debug($this->data); ?>
</fieldset>